package com.nc.user.controller;


import com.nc.user.model.dto.DataResourcesDto;
import com.nc.user.service.DataResourceService;
import com.plug.result.ReqPage;
import com.plug.result.RetResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@Api(tags = "资源接口")
@RestController
@RequestMapping("DataController")
public class DataController {
    @Autowired
    private DataResourceService dataResourceService;

    @ApiOperation("新增")
    @PostMapping("data")
    public RetResult addData(@RequestBody DataResourcesDto dataResourcesDto) {
        return dataResourceService.save(dataResourcesDto);
    }

    @ApiOperation("根据id更新")
    @PutMapping("data/{id}")
    public RetResult updateData(@PathVariable String id, @RequestBody DataResourcesDto dataResourcesDto) {
        dataResourcesDto.setId(id);
        return dataResourceService.save(dataResourcesDto);
    }

    @ApiOperation("分页查询")
    @PostMapping("find/all")
    public RetResult findAll(@RequestBody ReqPage reqPage) {
        return dataResourceService.findAll(reqPage);
    }
}
